package service

import (
	"transfer-service/internal/biz"
	"transfer-service/internal/global"
)

type Anti struct {
	antiGunUseCase  *biz.AntiGunUseCase
	antiCarUseCase  *biz.AntiCarUseCase
	spectrumUseCase *biz.SpectrumUseCase
	droneUseCase    *biz.DroneUseCase
}

func NewAntiService(
	antiGunUseCase *biz.AntiGunUseCase,
	antiCarUseCase *biz.AntiCarUseCase,
	spectrumUseCase *biz.SpectrumUseCase,
	droneUseCase *biz.DroneUseCase,
) *Anti {
	return &Anti{
		antiGunUseCase:  antiGunUseCase,
		antiCarUseCase:  antiCarUseCase,
		spectrumUseCase: spectrumUseCase,
		droneUseCase:    droneUseCase,
	}
}
func (s *Anti) StartTransfer() {
	err := global.APOOL.Submit(func() {
		s.antiGunUseCase.TransferData()
	})
	if err != nil {
		global.LOG.Error("反制枪数据转发协程异常:", err)
		return
	}
	err = global.APOOL.Submit(func() {
		s.antiCarUseCase.TransferData()
	})
	if err != nil {
		global.LOG.Error("反制车数据转发协程异常:", err)
		return
	}
	err = global.APOOL.Submit(func() {
		s.spectrumUseCase.TransferData()
	})
	if err != nil {
		global.LOG.Error("频谱数据转发协程异常:", err)
		return
	}
	err = global.APOOL.Submit(func() {
		s.droneUseCase.TransferData()
	})
	if err != nil {
		global.LOG.Error("无人机数据转发协程异常:", err)
		return
	}
	return
}
